package cn.com.joyplus.wechat.model;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by 王灏川(wangrs@qq.com) on 2017/8/11 0011.
 */
public class TemplateMessage implements Serializable{

    private static final long serialVersionUID = -3662767566827161257L;
    @JsonProperty("template_id")
    private String templateId;
    private String touser;
    private String url;
    private String topcolor;
    private Map<String, TemplateData> data = new HashMap<String, TemplateData>();


    public TemplateMessage() {
    }

    public TemplateMessage(String templateId,String touser) {
        this.templateId = templateId;
        this.touser = touser;
    }

    public void addFirstTemplateData(String value) {
        addFirstTemplateData(value,null);
    }
    public void addFirstTemplateData(String value, String color) {
        data.put("first", createTemplateData(value, color));
    }


    public void addKeyword1TemplateData(String value) {
        addKeyword1TemplateData(value, null);
    }

    public void addKeyword1TemplateData(String value, String color) {
        data.put("keyword1", createTemplateData(value, color));
    }

    public void addKeyword2TemplateData(String value) {
        addKeyword2TemplateData(value, null);
    }
    public void addKeyword2TemplateData(String value, String color) {
        data.put("keyword2", createTemplateData(value, color));
    }
    public void addKeyword3TemplateData(String value) {
        addKeyword3TemplateData(value, null);
    }
    public void addKeyword3TemplateData(String value, String color) {
        data.put("keyword3", createTemplateData(value, color));
    }
    public void addKeyword4TemplateData(String value) {
        addKeyword4TemplateData(value, null);
    }
    public void addKeyword4TemplateData(String value, String color) {
        data.put("keyword4", createTemplateData(value, color));
    }
    public void addRemarkTemplateData(String value) {
        addRemarkTemplateData(value, null);
    }
    public void addRemarkTemplateData(String value, String color) {
        data.put("remark", createTemplateData(value, color));
    }

    private TemplateData createTemplateData(String value, String color) {
        TemplateData td = new TemplateData();
        if (null != color) td.setColor(color);
        td.setValue(value);
        return td;
    }

    public String getTemplateId() {
        return templateId;
    }

    public void setTemplateId(String templateId) {
        this.templateId = templateId;
    }

    public String getTouser() {
        return touser;
    }

    public void setTouser(String touser) {
        this.touser = touser;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getTopcolor() {
        return topcolor;
    }

    public void setTopcolor(String topcolor) {
        this.topcolor = topcolor;
    }

    public Map<String, TemplateData> getData() {
        return data;
    }

}

